<?php

use think\migration\Seeder;

class AirQualityNcForecastHourData extends Seeder
{

    public function run()
    {
        $table = $this->table('air_quality_nc_forecast_hour');
        $rows = [];
        $num  = 168;
        $i    = 0;
        while ($num > 0) {
            $rows[] = [
                //step1:基本信息
                'region_id'      => '53',    //区域ID
                'station_id'   => '1',    //站点id

                //step2:时间
                'predict_time'   => date('Y-m-d H', time() + 3600 * $i) . ':00:00',   //预报时间-7天168小时
                'publish_time' => date('Y-m-d H', time()) . ':00:00',   //发布时间-7天168小时


                //step3:六参，注：我们呈现的3111个数字，GIS呈现的色块
                'pm10_data'    => $this->data(),  //PM10
                'pm25_data'    => $this->data(),  //PM2.5
                'so2_data'     => $this->data(),  //二氧化硫
                'no2_data'     => $this->data(),  //二氧化氮
                'co_data'      => $this->data(),  //一氧化碳
                'o3_data'      => $this->data(),  //臭氧

                //step4:aqi
                'aqi_data'     => $this->data(),  //PM10

                //step5:系统时间
                'create_time'  => date('Y-m-d H:i:s', time()),
            ];
            $num--;
            $i++;
        }

        $table->insert($rows)->save();
    }

    public function data()
    {
        $data = file_get_contents(__DIR__ . '/json/nc_forecast.json');
        return $data;
    }
}
